﻿using isvn.Base;
namespace isvn.Commands
{
    internal static class CommandFactory
    {
        public static void FormatArgs(string[] args)
        {
            if (null == args || 0 == args.Length)
                return;

            for (int i = 0; i < args.Length; i++)
            {
                if (!string.IsNullOrEmpty(args[i]))
                    args[i] = args[i].Trim('\r', '\n', ' ').ToLowerInvariant();
            }
        }

        public static ICommand Create(string[] args)
        {
            if (null == args || 0 == args.Length)
                return new Help();

            FormatArgs(args);

            switch (args[0])
            {
                case "empty":
                    return new Empty();
                case "xcopy":
                    return new xCopy();
                default:
                    return new Help();
            }
        }
    }
}
